package com.lzs.Service.Impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lzs.DAO.ReimbursementDAO;
import com.lzs.PO.Certificate;
import com.lzs.PO.Page;
import com.lzs.PO.Reimbursement;
import com.lzs.Service.ReimbursementService;

@Service
public class ReimbursementServiceImpl implements ReimbursementService {

	@Autowired
	private ReimbursementDAO reimbursementDAO;
	@Override
	public List<Reimbursement> findReimbursementByRuralIdAndYear(String rural_id, String year) {
		
		List<Reimbursement> reimbursements = this.reimbursementDAO.findReimbursementByRuralIdAndYear(rural_id,year);
		
		return reimbursements;
	}
	@Override
	public void addReimbursement(Map<String, Object> map) {

		this.reimbursementDAO.addReimbursement(map);
		
	}
	@Override
	public Page<Reimbursement> findReimbursementPagelist(String keyword, Integer pageSize, Integer pageNum) {
		
		List<Reimbursement> arealist = this.reimbursementDAO.findReimbursementList(keyword);

		int totalRecord = arealist.size();

		Page<Reimbursement> page = new Page<Reimbursement>(pageNum, pageSize, totalRecord);

		int startIndex = page.getStartIndex();

		page.setList(reimbursementDAO.findReimbursementPagelist(keyword, startIndex, pageSize));
		
		return page;
	}
	@Override
	public Reimbursement findReimbursementById(String reimbursement_id) {
		
		Reimbursement reimbursement = this.reimbursementDAO.findReimbursementById(reimbursement_id);
		
		return reimbursement;
	}
	@Override
	public void updateReimbursement(Map<String, Object> map) {
			
		this.reimbursementDAO.updateReimbursement(map);
		
	}

}
